package chapter03.demo3;
class Student1{
    String id;
    private String name;
    private int age;
    private int gender;
    public Student1(String s){
        name = s;
    }
    public Student1(String s,int g ,int a){
        name = s;
        gender = g;
        age = a;
    }
    public void print(){
        System.out.println("id:"+id+";name"+name+";age"+age);
    }
    public String getName(){
        return name;
    }
    public void setName(String s){
        name = s;
    }
    public void setAge(int n){
        if (n <= 0){
            System.out.println("年龄非法");
        }
        if (n >= 200){
            System.out.println("年龄超出200岁,非法");
        }
        age = n;
    }
    public void setGender(String s){
        if(s.equals('男')){
            gender=0;
        }else{
            gender = 1;
        }
    }
    public String getGender(){
        String g ;
        if(gender == 0){
            g = "男";
        }else{
            g = "女";
        }
        return g;
    }
}
public class demo3{
    public static void main (String[] args){
        //构造函数
        Student1 stu1 =new Student1("蘑菇头");
        System.out.println(stu1.getName());
        Student1 stu2 = new Student1("蘑菇头",0,21);

        System.out.println(stu2.getGender());

    }
}

